package model

import "gorm.io/gorm"

type Video struct {
	gorm.Model
	UserId       int    `gorm:"type:int;not null;commit:'用户Id'"`
	Title        string `gorm:"type:varchar(150);not null;commit:'标题'"`
	CollectCount int    `gorm:"type:int;not null;commit:'收藏数'"`
	LikeCount    int    `gorm:"type:int;not null;commit:'点赞数'"`
	Status       int    `gorm:"type:int;not null;default:0;commit:'0-待审核,1-审核通过,2-审核失败'"`
}

// 视频审核
func (v *Video) CheckVideo(db *gorm.DB, id, status int) error {
	err := db.Model(&Video{}).Where("id=?", id).Update("status", status).Error
	return err
}

// 创建视频
func (v *Video) CreateVideo(db *gorm.DB) error {
	err := db.Create(&v).Error
	return err
}
